<?php

namespace App\Admin\Controllers;

use App\Admin\Metrics\Examples;
use App\Http\Controllers\Controller;
use App\Models\Book;
use App\Models\BookCategory;
use App\Models\BorrowBook;
use App\Models\User;
use Dcat\Admin\Http\Controllers\Dashboard;
use Dcat\Admin\Layout\Column;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Widgets\Card;

class HomeController extends Controller
{
    public function index(Content $content)
    {
        return $content
            ->header('总览')
            ->body(function (Row $row) {

                $row->column(12,Card::make('欢迎使用极客图书管理系统',"系统采用 PHP + Mysql 开发"));

                $row->column(6, function (Column $column) {
                    $column->row(Card::make('', '<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
    <h2 class="ml-1 font-lg-1">'. User::count() .'</h2>
    <span class="mb-0 mr-1 text-80">总用户量</span>
</div>'));
                    $column->row(Card::make('', '<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
    <h2 class="ml-1 font-lg-1">'. BorrowBook::count() .'</h2>
    <span class="mb-0 mr-1 text-80">总借阅量</span>
</div>'));
                });

                $row->column(6, function (Column $column) {
                    $column->row(Card::make('', '<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
    <h2 class="ml-1 font-lg-1">'. Book::count() .'</h2>
    <span class="mb-0 mr-1 text-80">书籍数量</span>
</div>'));
                    $column->row(Card::make('', '<div class="d-flex justify-content-between align-items-center mt-1" style="margin-bottom: 2px">
    <h2 class="ml-1 font-lg-1">'. BookCategory::count() .'</h2>
    <span class="mb-0 mr-1 text-80">书籍分类数</span>
</div>'));
                });

            });
    }
}
